import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsNumber, Min, Max } from 'class-validator';

// 请求分页dto
export class RequestPaginationDto {
  @ApiPropertyOptional({
    description: '分页-每页多少条，最大100',
    type: Number,
  })
  @IsNumber()
  @Min(10)
  @Max(100)
  pageSize = 100;

  @ApiPropertyOptional({
    description: '分页-第几页，默认1',
    type: Number,
  })
  @IsNumber()
  @Min(1)
  pageNum = 1;
}

// 响应分页dto
export class ResponsePaginationDto {
  constructor(obj: ResponsePaginationDto) {
    this.list = obj.list;
    this.total = obj.total;
  }
  @ApiPropertyOptional({
    description: '分页总数',
    type: Number,
  })
  total = 0;

  @ApiPropertyOptional({
    description: '分页list数据',
    type: Array,
  })
  list: Array<any>;
}
